<template>
  <div>
    <el-col :span="24" class="bg1">
      <div class="grid-content bg-purple">
        <FormPanel ref="formPanel" :list="formList" :cols="3" :labelWidth="110" :isSubmitBtn="false" @formChange="changeHandle" />
      </div>
    </el-col>
    <!-- <el-col :span="24" class="bg2">
      <BreakSpace label="车辆处理措施" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
      <FormPanel ref="dealWay" :list="columnDealWay" :cols="3" :labelWidth="110" :isSubmitBtn="false" />
    </el-col> -->
    <el-col :span="24" class="bg2">
      <BreakSpace label="活动VIN列表" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
      <!-- :fetchapi="fetchApi"
        :params="fetchParams"-->
      <FilterTable
        ref="table"
        :onSyncTableData="vinTableChangeFun"
        selectionType="single"
        :isSelectColumn="false"
        :isMemoryPagination="isAdd"
        height="200"
        :columns="columns"
        :fetchapi="fetchapiVin"
        :params="fetchParamsVin"
        :dataSource="dataSource"
        datakey="records"
        columnsRef="yxqPjxmTable"
        :isColumnFilter="true"
        :onColumnsChange="(columns) => (this.columns = columns)"
        :onRowSelectChange="(arr) => (this.onChangeColumn = arr)"
      >
        <template slot="controls">
          <!-- <el-button size="small" :disabled="disableState || addBtnDisabled" type="primary" icon="el-icon-plus" @click="addVpn">添加VIN</el-button> -->
          <!--<el-button size="small" type="primary" icon="el-icon-import" @click="importHandle">VIN导入</el-button>-->
          <el-button size="small" :disabled="disableState || addBtnDisabled" type="primary" icon="el-icon-download" @click="downHandle">模板下载</el-button>

          <ImportUploadFile
            style="margin: 0 10px"
            :disabled="disableState || addBtnDisabled"
            isOnlyButton
            :limit="20"
            type="primary"
            :fileTypes="['xls', 'xlsx']"
            icon="el-icon-upload"
            :actionUrl="actionUrl"
            @change="successHandler"
            >VIN导入
          </ImportUploadFile>
        </template>
      </FilterTable>
    </el-col>

    <el-col :span="24" class="bg2">
      <BreakSpace label="维修工时" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
      <!--  :fetchapi="fetchApiSport"
              :params="fetchParamSport"-->
      <FilterTable
        ref="tableSport"
        selectionType="single"
        height="200"
        :isSelectColumn="false"
        :columns="columnSport"
        :onSyncTableData="sportTableChangeFun"
        :isMemoryPagination="true"
        columnsRef="yxqSportTable"
        :onColumnsChange="(columns) => (this.columnSport = columns)"
        :onRowSelectChange="(arr) => (this.onChangeColumn = arr)"
      >
        <template slot="controls">
          <el-button size="small" type="primary" icon="el-icon-plus" :disabled="disableState || addBtnDisabled" @click="addSport">添加活动项目</el-button>
        </template>
      </FilterTable>
    </el-col>

    <el-col :span="24" class="bg2">
      <BreakSpace label="维修备件" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>

      <!--   :fetchapi="fetchApiPeij"
        :params="fetchParamPeij"-->
      <FilterTable
        ref="tablePeij"
        height="200"
        :onSyncTableData="peijTableChangeFun"
        :onCellChange="onCellChange"
        :isSelectColumn="false"
        selectionType="single"
        :columns="columnPeij"
        :isMemoryPagination="true"
        columnsRef="yxqPeijTable"
        :onColumnsChange="(columns) => (this.columnPeij = columns)"
        :onRowSelectChange="(arr) => (this.onChangeColumn = arr)"
      >
        <template slot="controls">
          <el-button size="small" type="primary" icon="el-icon-plus" :disabled="disableState || addBtnDisabled" @click="addPeij">添加备件</el-button>
        </template>
      </FilterTable>
    </el-col>

    <el-col :span="24" class="bg2">
      <BreakSpace label="附加项目" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>

      <!--   :fetchapi="fetchApiPeij"
        :params="fetchParamPeij"-->
      <FilterTable
        ref="tableFuj"
        height="200"
        :onSyncTableData="fujTableChangeFun"
        :onCellChange="onCellChange"
        :isSelectColumn="false"
        selectionType="single"
        :columns="columnFuj"
        :isMemoryPagination="true"
        columnsRef="yxqFujTable"
        :onColumnsChange="(columns) => (this.columnFuj = columns)"
        :onRowSelectChange="(arr) => (this.onChangeColumn = arr)"
      >
        <template slot="controls">
          <el-button size="small" type="primary" icon="el-icon-plus" :disabled="disableState || addBtnDisabled" @click="addFuj">添加附加</el-button>
        </template>
      </FilterTable>
    </el-col>

    <!-- <el-col :span="24" class="bg2" v-if="handleType == 'edit'">
      <BreakSpace label="索赔审核信息" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>"-->

    <!--  :fetchapi="fetchApiSuopei"
        :params="fetchParamSuopei"-->
    <!--  <FilterTable
        ref="tableSuopei"
        height="200"
        :isSelectColumn="false"
        selectionType="single"
        :columns="columnSuopei"
        :isMemoryPagination="true"
        columnsRef="yxqSuopeiTable"
        :onColumnsChange="columns => (this.columnSuopei = columns)"
        :onRowSelectChange="arr => (this.onChangeColumn = arr)"
      >
      </FilterTable>
    </el-col> -->

    <div class="dialogBottmView">
      <multiuse-button type="primary" class="btnStyle" :disabled="disableState" :click="closeMenu.bind(this, 1)">保存</multiuse-button>

      <!-- <multiuse-button v-if="handleType == 'edit'" :disabled="!isClicked" type="primary" class="btnStyle" :click="closeMenu.bind(this, 2)">下发 </multiuse-button> -->

      <multiuse-button type="primary" class="btnStyle" :click="closeMenu.bind(this, 3)">关闭</multiuse-button>
    </div>
    <BaseDialog :visible.sync="visibleVin" title="VIN查询" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }" destroyOnClose>
      <add-vin @selectArr="selectFun" @closeVin="closeDialog"></add-vin>
    </BaseDialog>
    <!--mark  -->
    <BaseDialog :visible.sync="visibleSport" title="维修项目选择" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }" destroyOnClose>
      <add-sport @selectArr="selectSportFun" @closeVin="closeDialog"></add-sport>
    </BaseDialog>
    <!-- mark -->
    <BaseDialog :visible.sync="visibleFuj" title="附加项目选择" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }" destroyOnClose>
      <add-fuj @selectArr="selectFujFun" @closeVin="closeDialog"></add-fuj>
    </BaseDialog>
    <BaseDialog :visible.sync="visiblePeij" title="备件选择" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }" destroyOnClose>
      <add-peij :status="status" @selectArr="selectPeijFun" @closeVin="closeDialog" :powerType="powerType"></add-peij>
    </BaseDialog>
    <BaseDialog :visible.sync="suppliers" :title="'供应商选择'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <SupplierList @close="closeDialog" @save="suppliersSave" :rowDate="rowDate"></SupplierList>
    </BaseDialog>

    <!-- <BaseDialog :visible.sync="visibleDelear" title="选择经销商" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }" destroyOnClose>
      <add-delear :vin="selectObj['vin']" @selectArr="selectDelearFun" @closeDelear="closeDialog"></add-delear>
    </BaseDialog> -->
    <BaseDialog :visible.sync="visibleDelear" title="选择责任站" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }" destroyOnClose>
      <add-delear :vin="selectObj['vin']" @selectArr="selectDelearFun" @closeDelear="closeDialog"></add-delear>
    </BaseDialog>
    <BaseDialog :visible.sync="guzhangxianxiangdaima" :title="'故障现象选择'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <Selectguzhangxianxiang @close="closeDialog" @save="guzhangxianxiangdaimaSave"></Selectguzhangxianxiang>
    </BaseDialog>
    <BaseDialog :visible.sync="guzhangyuanyin" :title="'分类选择'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <Selectguzhangyuanyin @close="closeDialog" @save="guzhangyuanyinSave"></Selectguzhangyuanyin>
    </BaseDialog>
    <!-- <BaseDialog :visible.sync="visibleAdd" :title="'责任站选择'" destroyOnClose width="850px" :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <DealerList @close="closeAdd" @save="saveAdd"></DealerList>
    </BaseDialog> -->
  </div>
</template>

<script>
import {
  addTtRpMa,
  getByMaId,
  getDealer,
  delMaItem,
  downVinTem,
  getVinByMaId,
  saveDown,
  getAllUser,
  // queryUnitCode,
  byAllTranslate,
  getPartSupplier,
  findFileByUrl,
  getAddList,
} from '@/api/repair/batchEventManagement/activityDistribution';
import { dictionary } from '@/utils/dictMixin';
import addVin from './addVin';
import addDelear from './addDelear';
import DealerList from './DealerList';
import addSport from './addSport';
import addPeij from './addPeij';
import addFuj from './addFuj';
import { isEmpty } from '@/utils/utils';
import _ from 'lodash';
import { exportExcelFile } from '@/utils/index';
import { arrayObjDeWeight } from '@/utils';
import { dealerMixin } from '@/pages/repair/batchEventManagement/dealerMixin';
import moment from 'moment';
import { getAppId } from '@/assets/js/auth';
import Selectguzhangxianxiang from '@/pages/claimDemage/BasicData/ClaimApplication/Selectguzhangxianxiang.vue';
import Selectguzhangyuanyin from '@/pages/claimDemage/BasicData/ClaimApplication/Selectguzhangyuanyin.vue';
import SupplierList from '@/pages/claimDemage/tools/SuppliersList.vue';
import { partCodeP } from '@/utils/validate';
import config from '@/assets/js/config';

// import { findFileByUrl } from '@/api/partsmanage/financialManagement/capitalAccount/index';

export default {
  name: 'add',
  mixins: [dictionary, dealerMixin],
  /*handleType add 新增  edit  编辑*/
  props: ['handleType', 'maId', 'row'],
  data() {
    return {
      visibleAdd: false,
      txt: {},
      appendixName: '',
      // costType:58031002,
      saveData: null,
      columnSport: this.createTableColumnSport(),
      columnDealWay: this.createTableColumnDealWay(),
      columnPeij: this.createTableColumnPeij(),
      columnSuopei: this.createTableColumnSuopei(),
      columnFuj: this.createTableColumnFuj(),
      columns: this.createTableColumns(),
      formList: this.createFormList(),
      visibleVin: false,
      visibleSport: false,
      visibleFuj: false,
      suppliers: false,
      guzhangyuanyin: false,
      guzhangxianxiangdaima: false,
      visiblePeij: false,
      rowDate: {},
      faultId: '',
      frId: '',
      maStatus: '',
      visibleDelear: false,
      visibleMainCode: false,
      isAdd: this.handleType == 'add',
      fetchParams: { xhrAbort: true },
      fetchParamPeij: { xhrAbort: true },
      fetchParamSport: { xhrAbort: true },
      fetchParamSuopei: { xhrAbort: true },
      fetchParamFuj: { xhrAbort: true },

      dataSource: [],
      fetchApiPeij: '',
      fetchApi: '',
      fetchApiSport: '',
      fetchApiSuopei: '',
      fetchApiFuj: '',
      fetchapiVin: getVinByMaId,
      fetchParamsVin: { xhrAbort: true },
      onChangeColumn: [],

      /*活动删除列表数组*/
      delSportArr: [],
      /*配件删除列表数据*/
      delPartArr: [],
      /*vin删除列表数组*/
      delVinArr: [],
      /*附加删除列表数组 */
      delFujArr: [],

      vinArr: [] /**/,
      sportArr: [],
      peijArr: [],
      fujArr: [],
      status: 1 /*1  表单选择  2 新建配件*/,
      detailObj: {},
      UploadFileIsShow: false,
      /*是否可下发*/
      isClicked: false,
      /*vin对象 选择*/
      selectObj: {},

      // actionUrl: '/api/dmscloud.activity/ttRpMa/uploadVinTem',//本地

      actionUrl: `${config.uploadUrl}/api/dmscloud.activity/ttRpMa/uploadVinTem`, //uat环境
    };
  },
  computed: {
    //
    disableState() {
      return this.row.ifClaim == 10041001;
    },
    // 质量部下发数据不允许新增
    addBtnDisabled() {
      // return this.row.dataSource == 10151001;
      return false;
    },
    powerType() {
      return this.handleType == 'add' ? 50001002 : this.row.dataSource == 10151001 ? 50001001 : 50001002;
    },
  },
  components: {
    addVin,
    addSport,
    addPeij,
    addDelear,
    addFuj,
    SupplierList,
    DealerList,
    Selectguzhangyuanyin,
    Selectguzhangxianxiang,
  },
  mounted() {
    console.log('maId---', this.maId);

    this.BaseTable = this.$refs.table.$refs.pageTable;
    this.BaseSportTable = this.$refs.tableSport.$refs.pageTable;
    this.BasePeijTable = this.$refs.tablePeij.$refs.pageTable;
    this.BaseFujTable = this.$refs.tableFuj.$refs.pageTable;

    // debugger
    // this.getAllDelears(this.columns, ['salesDealer', 'resDealer'], 'table');

    if (this.handleType == 'edit') {
      // this.BaseSuopeiTable = this.$refs.tableSuopei.$refs.pageTable;
      // this.DealWayTable = this.$refs.dealWay.$refs.pageTable;
      this.getData();
      // 处理是否索赔通过审核
      if (this.row.ifClaim == 10041001) {
        this.handleClaim();
        this.columnPeij.find((x) => x.dataIndex == 'counts').editRequired = false;
        this.columnPeij.find((x) => x.dataIndex == 'counts').editable = false;
      }
    }
    this.getUnit();

    this.initSelect();

    // this.initDelear();
  },
  created() {},
  methods: {
    suppliersSave(obj) {
      this.formList.find((x) => x.fieldName == 'supName').initialValue = obj[0].supName;
      this.formList.find((x) => x.fieldName == 'supCode').initialValue = obj[0].supCode;
      this.closeDialog();
    },
    cheageselect(data) {
      console.log(data, 111111);
      this.txt.data;
    },
    chooseDealerNo() {
      this.visibleAdd = true;
    },
    closeAdd() {
      this.visibleAdd = false;
      this.fetchParams = { ...this.fetchParams };
    },
    saveAdd(obj) {
      this.formList.map((x) => {
        if ('dealerCode' == x.fieldName) {
          x.initialValue = obj[0].dealerCode;
        }
        if ('dealerName' == x.fieldName) {
          x.initialValue = obj[0].dealerName;
        }
      });
      this.visibleAdd = false;
    },
    handleClaim() {
      // 禁用所有的编辑项，只可以下发和关闭
      this.formList.forEach((x) => {
        x.disabled = true;
        x.rules = [];
        x.placeholder = '';
      });
    },
    async getUnit() {
      // this.getAllUnitCode(this.columnPeij, ['unit'], 'table');
      // const res = await queryUnitCode();
      // this.columns.find(item => item.dataIndex === 'salesDealer').dictItems = res.data.map(x => ({
      //   text: x.UNIT_NAME,
      //   value: x.UNIT_CODE
      // }));
    },

    /*配置数量发生改变的时候执行*/
    onCellChange(e, obj) {
      let counts = isEmpty(obj['counts']) ? '0' : obj['counts'];
      let price = isEmpty(obj['price']) ? '0' : obj['price'];
      let amount = obj['amount'];

      let toatalCount = counts * price ? counts * price : 0;
      if (obj['partFrom'] == 10251002) {
        obj['amount'] = 0.0;
      } else {
        obj['amount'] = toatalCount.toFixed(2);
      }

      this.BasePeijTable.DO_REFRESH(false);

      // this.columnPeij.find((item,index)=>item.dataIndex=='amount').initialValue=1//toatalCount
    },

    async initSelect() {
      this.getAllUsers(this.columnSuopei, ['createdBy'], 'table');
    },

    async initDelear() {
      let res = await byAllTranslate();
      let dataList = arrayObjDeWeight(res.data, 'userId');
      this.columnSuopei.find((item) => item.dataIndex === 'createdBy').dictItems = dataList.map((x) => ({
        text: x.dealerName,
        value: x.dealerCode,
      }));
    },

    /*导入*/
    importHandle() {
      this.handleType = 'import';
      this.UploadFileIsShow = true;
    },
    /*下载模板*/
    downHandle() {
      this.handleType = 'down';
      this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
        confirmButtonText: '下载',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          downVinTem()
            .then((res) => {
              console.log(res, 'res');
              exportExcelFile(res.data, 'vin模板');
            })
            .catch((err) => {});
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消',
          });
        });
    },

    /**
     * 根据数组对象的某个字段去重
     * item.name  是[{name:1}] 根据每条数据的name值来去重
     * */
    unique(arr, val) {
      const res = new Map();
      return arr.filter((item) => !res.has(item[val]) && res.set(item[val], 1));
    },

    successHandler(e) {
      console.log('e:::', e);
      if (e != 1) {
        let obj = e[e.length - 1];
        let data = obj['url'];
        console.log(data + '999999999999999');
        // let success = data['success'];
        let successArr = data['success'];
        let newArr = [];
        let cfArr = [];
        // successArr.forEach((item, index) => {
        //   if (this.vinArr.length > 0) {
        //     this.vinArr.forEach((obj, pos) => {
        //       if (item['vin'] != obj['vin']) {
        //         newArr.push(item);
        //         // this.$refs.table.EXECUTE_INSERT(item);
        //       }
        //     });
        //   } else {
        //     newArr.push(item);
        //     // this.$refs.table.EXECUTE_INSERT(item);
        //   }
        // });
        let count = 0;
        successArr.forEach((item, index) => {
          if (this.vinArr.length > 0) {
            this.vinArr.forEach((obj, pos) => {
              if (item['vin'] != obj['vin']) {
                newArr.push(item);
              } else {
                count = count + 1;
                cfArr.push(item['vin']);
              }
            });
          }
        });
        console.log('cfArr' + cfArr);
        this.$notify.success({ title: '提示信息', message: '您共成功导入' + (successArr.length-count) + '条数据,该活动中已存在' + cfArr.join(',\n') +'不允许导入' });
        if (newArr.length === 0) {
          newArr = successArr.concat(this.vinArr);
        } else {
          newArr = this.vinArr.concat(newArr);
          // newArr = newArr.concat(this.vinArr);
        }
        let tempArr = this.unique(newArr, 'vin');

        this.dataSource = tempArr;

        this.BaseTable.STOP_LOADING();
      } else {
        if (e.errMsg == '当前excel为空，或检查下导入数据模板格式是否正确。') {
          this.$notify.error({ title: '提示信息', message: '请导入符合格式的数据' });
        }
        // this.BaseTable.START_LOADING();
        // this.$notify.error({ title: '提示信息', message: "请导入符合格式的数据" });
      }
      this.UploadFileIsShow = false;
    },

    /*根据ID查询*/
    async getData() {
      // debugger
      let res = await getByMaId({ maId: this.maId });
      this.fetchParamsVin = Object.assign({}, this.fetchParamsVin, { maId: this.maId, xhrAbort: false });
      if (res.resultCode == 200 && res.success == true) {
        let data = isEmpty(res['data']) ? {} : res['data'];

        let ifPart = isEmpty(data['ifPart']) ? '' : data['ifPart'];
        let ifTech = isEmpty(data['ifTech']) ? '' : data['ifTech'];
        let ifClaim = isEmpty(data['ifClaim']) ? '' : data['ifClaim'];

        let flag = data['ifSettle'] == 10041001 ? 10041001 == ifTech && 10041001 == ifClaim : 10041001 == ifTech;

        if (flag) {
          this.isClicked = true;
        } else {
          this.isClicked = false;
        }
        // let ttRpMaAreas = data['ttRpMaAreas'];
        let ttRpMaLabours = data['ttRpMaLabours'];
        let ttRpMaParts = data['ttRpMaParts'];
        this.sportArr = ttRpMaLabours;
        // let ttRpMaLogVOS = data['ttRpMaLogVOS'];
        let ttRpMaAddVOS = data['ttRpMaAddVOS'];

        // this.BaseTable.EXECUTE_INSERT(ttRpMaAreas);
        this.BaseSportTable.EXECUTE_INSERT(ttRpMaLabours);
        this.BasePeijTable.EXECUTE_INSERT(ttRpMaParts);
        // this.BaseSuopeiTable.EXECUTE_INSERT(ttRpMaLogVOS);
        this.BaseFujTable.EXECUTE_INSERT(ttRpMaAddVOS);
        this.faultId = data.faultId;
        this.frId = data.frId;
        this.maStatus = data.maStatus;
        this.appendixName = data.appendixName;

        for (let i in data) {
          this.formList.map((x) => {
            if (i == x.fieldName) {
              x.initialValue = data[i];
            }
          });
        }

        this.appendixName = data.appendixName ? JSON.parse(data.appendixName) : [];
        this.appendixAddress = data.appendixAddress ? JSON.parse(data.appendixAddress) : [];

        // 数据组装
        const files = [];
        if (this.appendixName) {
          this.appendixName.forEach((name, index) => {
            files.push({
              name,
              url: this.appendixAddress[index],
            });
          });
          console.log(111, files);

          // 数据赋值
          this.formList.find((x) => {
            x.fieldName === 'appendixAddress' && (x.initialValue = files);
          });
        }
      }
    },

    peijTableChangeFun(val) {
      this.peijArr = val;
    },
    fujTableChangeFun(val) {
      this.fujArr = val;
    },

    vinTableChangeFun(val) {
      this.vinArr = val;
      console.log('val---', val);
    },

    sportTableChangeFun(val) {
      this.sportArr = val;
      console.log('val---', val);
    },

    async closeMenu(type) {
      if (type == '3') {
        this.$emit('close');
      } else {
        if (type == '1') {
          //保存
          /*保存数据*/
          this.$refs.formPanel.SUBMIT_FORM();
          // this.$refs.tablePeij.SUBMIT_FORM();

          let obj = {
            ...this.saveData,

            maId: isEmpty(this.maId) ? '' : this.maId,
            ttRpMaDealerDtos: this.vinArr,
            ttRpMaPartVos: this.peijArr,
            ttRpMaLabourVos: this.sportArr,
            // ttRpMaAddVos: this.fujArr,
            ttRpMaAreaVoDel: this.delVinArr,
            ttRpMaLabourVoDel: this.delSportArr,
            ttRpMaPartVoDel: this.delPartArr,
            // ttRpMaAddVoDel: this.delFujArr,
          };

          // obj.maId = isEmpty(this.maId) ? '' : this.maId;

          // obj.ttRpMaDealerDtos = this.vinArr;
          // obj.ttRpMaLabourVos = this.sportArr;
          // obj.ttRpMaPartVos = this.peijArr;
          obj.ttRpMaAddVos = this.fujArr;

          // console.log("this.fujArr"+this.fujArr[0].item);
          // console.log('this.fujArr' + this.fujArr[0].itemCode);
          // debugger;

          // obj.ttRpMaDealerDTOSDel = this.delVinArr;
          // obj.ttRpMaLabourVODel = this.delSportArr;
          // obj.ttRpMaPartVODel = this.delPartArr;
          obj.ttRpMaAddVoDel = this.delFujArr;

          let editDate = isEmpty(obj.editDate) ? '0' : obj.editDate;

          let eDate = isEmpty(obj.eDate) ? '0' : obj.eDate;
          let bDate = isEmpty(obj.bDate) ? '0' : obj.bDate;

          if (moment(eDate) < moment(bDate)) {
            this.$notify.warning({ title: '提示信息', message: '活动截止日期不能小于开始日期' });
            return;
          }

          // vin列表为空需要提示
          if (!this.vinArr.length) {
            this.$notify.warning({ title: '提示信息', message: 'VIN列表不能为空！！！' });
            return;
          }

          // 维修工时为空需要提示
          if (!this.sportArr.length) {
            this.$notify.warning({ title: '提示信息', message: '维修工时不能为空！！！' });
            return;
          }
          //数量不能为空
          // let flag = false;
          // console.log(this.peijArr, 'this.peijArr::::');
          // if (this.peijArr.length) {
          //   this.peijArr.forEach((x) => {
          //     // /^([1-9]\d*((.\d+)*))|(0.\d+)$/
          //     if ((x.counts)<0 && (x.counts)==0) {
          //       flag = true;
          //     }
          //   });
          // }
          // if (flag) {
          //   this.$notify.warning({ title: '提示信息', message: '数量必须大于0！！！' });
          //   return;
          // }
          //配件渠道不能为空
          // let flagQD = false;
          // if (this.peijArr.length) {
          //   this.peijArr.forEach(x => {
          //     if (!x.partFrom || x.partFrom == '') {
          //       flagQD = true;
          //     }
          //   });
          // }
          // if (flagQD) {
          //   this.$notify.warning({ title: '提示信息', message: '配件渠道不能为空' });
          //   return;
          // }

          // if ((parseInt(editDate) < 0 || parseInt(editDate) == 0) && this.handleType == 'edit') {
          //   this.$notify.warning({ title: '提示信息', message: '经销商修改销售状态时效只能是整数并且大于0' });
          //   return;
          // }

          obj.bDate = moment(obj.bDate).format('YYYY-MM-DD HH:mm:ss');
          obj.eDate = moment(obj.eDate).format('YYYY-MM-DD HH:mm:ss');
          obj.verifyDate = moment(obj.verifyDate).format('YYYY-MM-DD HH:mm:ss');

          let tempArray = this.peijArr.filter((item) => {
            return item.counts == '' || item.counts == undefined || item.counts == 'undefined' || item.counts == 'null' || item.counts == null;
          });

          //if (tempArray.length > 0) {
          //  this.$notify.warning({ title: '提示信息', message: '请将配件中数量信息维护完整' });
          //  return;
          //}

          if (this.handleType == 'add') {
            obj.maId = '';
          }
          obj.frId = this.frId;
          obj.faultId = this.faultId;
          obj.appendixName = this.appendixName;
          obj.maStatus = this.maStatus;
          let res = await addTtRpMa(obj);

          if (res.resultCode == 200 && res.success == true) {
            this.$emit('close', 'refresh');
            this.$notify.success({ title: '提示信息', message: '操作成功' });
          } else {
            // let errMsg = isEmpty(res.errMsg) ? '操作失败' : res.errMsg;

            this.$notify.error({ title: '提示信息', message: errMsg });
          }
        } else if (type == '2') {
          let eDate = this.formList.find((item) => item.fieldName == 'eDate').initialValue;
          let bDate = this.formList.find((item) => item.fieldName == 'bDate').initialValue;

          if (moment(eDate) < moment(bDate)) {
            this.$notify.warning({ title: '提示信息', message: '活动截止日期不能小于开始日期' });
            return;
          }

          // vin列表为空需要提示
          if (!this.vinArr.length) {
            this.$notify.warning({ title: '提示信息', message: 'VIN列表不能为空！！！' });
            return;
          }

          let curDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');

          if (moment(eDate) < moment(curDate)) {
            this.$notify.warning({ title: '提示信息', message: '活动截止日期不能小于当前日期' });
            return;
          }
          //数量不能为空
          let flag = false;
          if (this.peijArr.length) {
            this.peijArr.forEach((x) => {
              if (_.isNil(x.counts)) {
                flag = true;
              }
            });
          }
          // if (flag) {
          //   this.$notify.warning({ title: '提示信息', message: '数量不能为空！！！' });
          //   return;
          // }

          // validator: (rule, value, callback) => {
          //   let reg = /^(\d+)(\.?)(\d{0,2})$/;
          //   if (!reg.test(Number(value))) {
          //     return callback(new Error('数量,最多2位小数...'));
          //   }
          //   callback();
          // },

          let flag2 = false;
          if (this.peijArr.length) {
            this.peijArr.forEach((x) => {
              (rule, value, callback) => {
                let reg = /^(\d+)(\.?)(\d{0,2})$/;
                value = x.counts;
                debugger;
                if (!reg.test(Number(value))) {
                  this.$notify.warning({ title: '提示信息', message: '数量,最多2位小数...' });
                  return callback(new Error('数量,最多2位小数...'));
                }
                callback();
                flag2 = true;
              };
            });
          }
          // if (flag2) {
          //   this.$notify.warning({ title: '提示信息', message: '数量不能为空！！！' });
          //   return;
          // }

          // let flag2 = false;
          // if (this.peijArr.length) {
          //   this.peijArr.forEach(x => {

          //     if (/^(\d+)(\.?)(\d{0,2})$/.test(x.counts)) {
          //       flag2 = true;
          //     }
          //   });
          // }
          // if (flag2) {
          //   this.$notify.warning({ title: '提示信息', message: '数量最多2位小数！！！' });
          //   return;
          // }

          //备件不能为空
          let flag1 = false;
          if (this.peijArr.length) {
            this.peijArr.forEach((x) => {
              if (_.isNil(x.mlId)) {
                flag1 = true;
              }
            });
          }
          if (flag1) {
            this.$notify.warning({ title: '提示信息', message: '关联维修工时不能为空！！！' });
            return;
          }

          let res = await saveDown({ maId: this.maId });

          if (res.resultCode == 200 && res.success == true) {
            this.$emit('close', 'refresh');
            this.$notify.success({ title: '提示信息', message: '操作成功' });
          } else {
            // let errMsg = isEmpty(res.errMsg) ? '操作失败' : res.errMsg;
            //
            // this.$notify.error({title: '提示信息', message: errMsg});
          }
        }
      }
    },
    changeOneAmount(val) {
      if (val == 10041001) {
        this.formList.find((x) => x.fieldName == 'oneAmount').disabled = false;
        this.formList.find((x) => x.fieldName == 'oneAmount').rules = [{ required: true, trigger: 'change', message: '一口价为是时金额不能为空' }];
      } else {
        this.formList.find((x) => x.fieldName == 'oneAmount').disabled = true;
        this.formList.find((x) => x.fieldName == 'oneAmount').rules = [];
      }
    },
    closeDialog() {
      console.log('关闭');
      this.guzhangxianxiangdaima = false;
      this.guzhangyuanyin = false;
      this.visibleVin = false;
      this.visibleSport = false;
      this.visibleFuj = false;
      this.visiblePeij = false;
      this.visibleDelear = false;
      this.suppliers = false;
    },

    /*flag   part:配件删除  area：vin删除  labour ： 项目删除*/
    async delByEdit(flag, id, row) {
      /*本地删除数据*/
      if (isEmpty(id)) {
        if (flag == 'area') {
          this.BaseTable.EXECUTE_DELETE([row]);
        } else if (flag == 'labour') {
          this.BaseSportTable.EXECUTE_DELETE([row]);
        } else if (flag == 'add') {
          this.BaseFujTable.EXECUTE_DELETE([row]);
        } else {
          this.BasePeijTable.EXECUTE_DELETE([row]);
        }
      } else {
        // let res = await delMaItem({'flag': flag, 'id': id, 'maId': this.maId});
        // if (res.resultCode == 200 && res.success == true)
        // {
        //   this.$notify.success({title: '提示信息', message: '操作成功'});
        if (flag == 'area') {
          this.delVinArr.push(id);
          this.BaseTable.EXECUTE_DELETE([row]);
        } else if (flag == 'labour') {
          this.delSportArr.push(id);
          this.BaseSportTable.EXECUTE_DELETE([row]);
        } else if (flag == 'add') {
          this.delFujArr.push(id);
          this.BaseFujTable.EXECUTE_DELETE([row]);
        } else {
          this.delPartArr.push(id);
          this.BasePeijTable.EXECUTE_DELETE([row]);
        }
        // }
      }
    },

    /*vin删除*/
  vinDelFun(row) {
      if((row.doStatus == '55351002' | row.doStatus == '55351003')){
        this.$notify.warning({ title: '提示信息', message: '该车已参加活动，不允许删除' });

      }else{
          if (this.handleType == 'edit') {
            this.delByEdit('area', row['areaId'], row);
          } else {
            this.BaseTable.EXECUTE_DELETE([row]);
          }
      }
    },

    /*配件删除*/
    peijDelFun(row) {
      if (this.handleType == 'edit') {
        this.delByEdit('part', row['mpId'], row);
      } else {
        this.BasePeijTable.EXECUTE_DELETE([row]);
      }
    },
    /*附加删除*/
    fujDelFun(row) {
      if (this.handleType == 'edit') {
        this.delByEdit('add', row['maId'], row);
      } else {
        this.BaseFujTable.EXECUTE_DELETE([row]);
      }
    },
    // /*选择经销商*/
    // selectDelearFun(arr) {
    //   if (!isEmpty(this.selectObj)) {
    //     let index = this.selectObj['$index'];

    //     let dealerShortname = arr[0].dealerShortname;

    //     let dealerCode = arr[0].dealerCode;
    //     let name = arr[0].name;
    //     let mobile = arr[0].mobile;

    //     this.vinArr[index].resDealer = dealerCode;

    //     this.vinArr[index].dealerShortname = dealerShortname;
    //     this.vinArr[index].name = name;
    //     this.vinArr[index].mobile = mobile;

    //     // this.BaseTable.DO_REFRESH(false);
    //   }
    // },

    /*选择责任站*/
    selectDelearFun(arr) {
      if (!isEmpty(this.selectObj)) {
        let index = this.selectObj['$index'];

        console.log(index, this.vinArr);

        let dealerName = arr[0].dealerName;

        let dealerCode = arr[0].dealerCode;

        // this.$set(this.vinArr,index,"dealerCode",dealerCode);
        // this.$set(this.vinArr,index,"dealerName",dealerName);

        this.$set(this.vinArr, index, { ...this.vinArr[index], dealerCode: dealerCode, dealerName: dealerName });

        // this.vinArr[index].dealerCode = dealerCode;

        // this.vinArr[index].dealerName = dealerName;
        this.dataSource = this.vinArr;

        console.log('dataSource', this.dataSource);
        // debugger
        // this.columns.find((x) => {
        //   if(x.dataIndex == 'dealerCode') {
        //        x.initialValue = dealerCode;
        //        console.log();

        //     }

        //   if(x.dataIndex == 'dealerName') {

        //     x.initialValue = dealerName;
        //     }

        //   });
        console.log(this.vinArr[index].dealerCode, 111111);
        console.log(this.vinArr[index].dealerName);
        console.log('dealerCode:' + dealerCode + 'dealerName:' + dealerName);
        // this.BaseTable.DO_REFRESH(false);
      }
    },
    /*配件 */
    async selectPeijFun(arr) {
      this.closeDialog();

      if (this.status == 1) {
        /*表单选择*/
        console.log('表单');
        this.formList.find((item) => item.fieldName == 'partCode').initialValue = arr[0].partCode;
        this.formList.find((item) => item.fieldName == 'partName').initialValue = arr[0].partName;
        let params = {};
        params.addId = getAppId();
        params.bjxmbh = arr[0].partCode;
        this.rowDate.partCode = arr[0].partCode;
        let res = await getPartSupplier(params);
        if (res.resultCode == 200 && res.data && res.data.records && res.data.records.length > 0) {
          this.formList.find((x) => x.fieldName == 'supName').initialValue = res.data.records[0].bjgyjc;
          this.formList.find((x) => x.fieldName == 'supCode').initialValue = res.data.records[0].bjgybm;
        }
      } else {
        console.log('新建配件');
      }
      let newArr = [];
      arr.forEach((item, index) => {
        var pos = this.peijArr.findIndex((value, index, arr) => {
          if (value['partCode'] == item['partCode']) {
            /*如果存在则更新数量*/
            if (!isEmpty(item['amount'])) {
              value['amount'] = item['amount'];
            }
            if (!isEmpty(item['counts'])) {
              value['counts'] = item['counts'];
            }
          }
          return value['partCode'] == item['partCode'];
        });
        if (pos == -1) {
          newArr.push(item);
        }
      });

      this.BasePeijTable.EXECUTE_INSERT(newArr);
      // this.BasePeijTable.DO_REFRESH();
    },

    /*VIN  添加*/
    selectFun(arr) {
      this.closeDialog();

      let newArr = [];
      arr.forEach((item, index) => {
        var pos = this.vinArr.findIndex((value, index, arr) => {
          return value['vin'] == item['vin'];
        });
        if (pos == -1) {
          newArr.push(item);
        }
      });

      this.BaseTable.EXECUTE_INSERT(newArr);
    },

    /*活动删除*/
    sportDelFun(row) {
      if (this.handleType == 'edit') {
        this.delByEdit('labour', row['mlId'], row);
      } else {
        this.BaseSportTable.EXECUTE_DELETE([row]);
      }
    },

    /*添加 活动*/
    selectSportFun(arr) {
      this.closeDialog();

      let newArr = [];
      arr.forEach((item, index) => {
        var pos = this.sportArr.findIndex((value, index, arr) => {
          return value['labourId'] == item['labourId'];
        });
        if (pos == -1) {
          newArr.push(item);
        }
      });
      this.BaseSportTable.EXECUTE_INSERT(newArr);
    },
    /*添加 附加 */
    selectFujFun(arr) {
      // debugger;
      this.closeDialog();

      let newArr = [];
      arr.forEach((item, index) => {
        var pos = this.fujArr.findIndex((value, index, arr) => {
          // return value['areaId'] == item['areaId'];
          return value['itemCode'] == item['itemCode'];
        });
        if (pos == -1) {
          newArr.push(item);
        }
      });

      this.BaseFujTable.EXECUTE_INSERT(newArr);
    },
    selectSuppliersCode() {
      this.suppliers = true;
    },
    query() {
      this.$refs.formPanel.SUBMIT_FORM();
    },
    reset() {
      this.$refs.formPanel.RESET_FORM();
      this.changeHandle();
    },
    changeHandle(val) {
      this.saveData = val;
    },

    seacherFun() {
      this.status = 1;
      this.visiblePeij = true;
    },
    selectfaultCode() {
      this.guzhangxianxiangdaima = true;
    },
    selectfaultReason() {
      this.guzhangyuanyin = true;
    },
    guzhangyuanyinSave(obj) {
      this.formList.find((x) => x.fieldName == 'frCode').initialValue = obj[0].frCode;
      this.formList.find((x) => x.fieldName == 'frName').initialValue = obj[0].frName;
      this.formList.find((f) => f.fieldName == 'frCode').readonly = true;
      this.formList.find((f) => f.fieldName == 'frName').readonly = true;
      this.frId = obj[0].frId;
      this.guzhangyuanyin = false;
    },
    guzhangxianxiangdaimaSave(obj) {
      this.formList.find((x) => x.fieldName == 'sysCode1').initialValue = obj[0].sysCode1;
      this.formList.find((x) => x.fieldName == 'sysName1').initialValue = obj[0].sysName1;
      this.formList.find((x) => x.fieldName == 'sysCode2').initialValue = obj[0].sysCode2;
      this.formList.find((x) => x.fieldName == 'sysName2').initialValue = obj[0].sysName2;
      this.formList.find((x) => x.fieldName == 'sysCode3').initialValue = obj[0].sysCode3;
      this.formList.find((x) => x.fieldName == 'sysName3').initialValue = obj[0].sysName3;
      this.formList.find((x) => x.fieldName == 'sysCode4').initialValue = obj[0].sysCode4;
      this.formList.find((x) => x.fieldName == 'sysName4').initialValue = obj[0].sysName4;
      this.formList.find((x) => x.fieldName == 'faultCode').initialValue = obj[0].faultCode;
      this.formList.find((x) => x.fieldName == 'faultName').initialValue = obj[0].faultName;
      this.faultId = obj[0].faultId;
      this.formList.find((f) => f.fieldName == 'faultCode').readonly = true;
      this.formList.find((f) => f.fieldName == 'faultName').readonly = true;
      this.guzhangxianxiangdaima = false;
    },
    /*添加配件*/
    addPeij() {
      this.status = 2;
      this.visiblePeij = true;
    },

    /*添加活动*/
    addSport() {
      this.visibleSport = true;
    },

    /*添加附加*/
    addFuj() {
      this.visibleFuj = true;
    },
    /*添加vpn*/
    addVpn() {
      this.visibleVin = true;
    },
    /*选择经销商*/
    // showDelearFun(row) {
    //   this.selectObj = row;
    //   this.visibleDelear = true;
    // },
    /*选择责任站*/
    showDelearFun(row) {
      this.selectObj = row;
      this.visibleDelear = true;
    },
    createTableColumnDealWay() {
      return [
        {
          type: 'INPUT',
          label: '结算金额',
          fieldName: 'settlementAmount',
          placeholder: '请选择',
          disabled: true,
          initialValue: '',
        },
        {
          type: 'INPUT',
          label: '原因分析',
          fieldName: 'causeAnalysis',
          placeholder: '请选择',
          disabled: true,
          initialValue: '',
        },
        {
          type: 'INPUT',
          label: '措施制定',
          fieldName: 'maStrategy',
          placeholder: '请选择',
          disabled: true,
          initialValue: '',
        },
        {
          type: 'INPUT',
          label: '市场车辆实施措施',
          fieldName: 'marketMeasures',
          placeholder: '请选择',
          disabled: true,
          initialValue: '',
        },
        {
          type: 'INPUT',
          label: '销售配件实施措施',
          fieldName: 'partMeasures',
          placeholder: '请选择',
          disabled: true,
          initialValue: '',
        },
        {
          type: 'BREAK_SPACE',
          label: 'fqms附件信息',
        },
        // {
        //   type: 'INPUT',
        //   label: '批量报告附件名称',
        //   fieldName: 'appendixName',
        //   placeholder: '请选择',
        //   disabled: true,
        //   initialValue: '',
        // },
        // {
        //   type: 'UPLOAD_FILE',
        //   label: '批量报告附件地址',
        //   fieldName: 'appendixAddress',
        //   placeholder: '请选择',
        //   disabled: true,
        //   fCols: 2,
        //   initialValue: '',
        // },
        {
          type: 'INPUT',
          label: '作业指导书名称',
          fieldName: 'guidanceName',
          placeholder: '请选择',
          disabled: true,
          initialValue: '',
        },
        {
          type: 'UPLOAD_FILE',
          label: '作业指导书地址',
          fieldName: 'guidnaceAddress',
          placeholder: '请选择',
          fCols: 2,
          disabled: true,
          initialValue: '',
        },
      ];
    },
    createFormList() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '批量活动基本信息',
        },

        {
          type: 'INPUT',
          label: '活动编号：',
          fieldName: 'maNo',
          itemList: [],
          // disabled: true,
          placeholder: '请输入',
          disabled: this.handleType == 'edit' ? true : false,
          rules: [
            { required: true, validator: partCodeP, trigger: 'blur' },
            { required: true, message: '活动编号不能为空', trigger: 'blur' },
            { max: 30, message: '活动编号为30个字符', trigger: 'blur' },
          ],
          initialValue: '',
        },
        {
          type: 'INPUT',
          label: '活动名称：',
          fieldName: 'maTitle',
          // disabled: true,
          disabled: this.handleType == 'edit' ? true : false,
          rules: [
            { required: true, trigger: 'change', message: '活动名称不能为空' },
            { max: 30, message: '活动名称为30个字符', trigger: 'blur' },
          ],
          placeholder: '请输入',
          initialValue: '',
        },

        {
          type: 'DATE',
          label: '活动开始日期：',
          fieldName: 'bDate',
          format: 'yyyy-MM-dd',
          disabled: this.handleType == 'edit' ? false : false,
          placeholder: '请选择',
          rules: [{ required: true, trigger: 'change', message: '活动开始日期不能为空' }],
          initialValue: '',
        },

        {
          type: 'DATE',
          label: '活动截止日期：',
          fieldName: 'eDate',
          format: 'yyyy-MM-dd',
          disabled: this.handleType == 'edit' ? false : false,
          placeholder: '请选择',
          rules: [{ required: true, trigger: 'change', message: '活动截止日期不能为空' }],
          initialValue: '',
        },
        {
          type: 'SELECT',
          label: '活动类型：',
          fieldName: 'maStrategy',
          placeholder: '请选择',
          // disabled: this.handleType == 'edit' ? true : false,
          rules: [{ required: true, trigger: 'change', message: '活动类型不能为空' }],
          itemList: this.createDictList(5080),
          initialValue: '',
        },
        {
          type: 'TEXT_AREA',
          label: '活动说明：',
          fieldName: 'maRemarks',
          placeholder: '请选择',
          // disabled: this.handleType == 'edit' ? false : false,
          rules: [{ required: false, trigger: 'change' }],
          initialValue: '',
          selfCols: 3,
        },

        {
          type: 'UPLOAD_FILE',
          label: '附件',
          fieldName: 'appendixAddress',
          initialValue: [],
          selfCols: 4,
          upload: {
            actionUrl: '/api/file/oss/upload',
            limit: 5,
            // tipText: '只能上传pdf格式'
          },
          // upload: {
          //   // actionUrl: '/api/file/oss/upload',
          //   actionUrl: `${config.uploadUrl}/api/file/v1/file/upload`,
          //   // fileTypes: ['pdf', 'jpg', 'png', 'rar'],
          //   limit: 5,
          //   max: 1024 * 100,
          // },
          change: (res) => {
            console.log(1, '文件上传回调', res);
          },
        },
      ];
    },

    /*索赔*/
    createTableColumnSuopei() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: (props) => {
            return <span>{props.row.index + 1}</span>;
          },
        },
        {
          title: '操作人',
          dataIndex: 'createdBy',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [],
          dictItems: [],
        },
        {
          title: '操作时间',
          dataIndex: 'createdAt',
          sorter: true,
          filter: true,
          filterType: 'date-range',
        },
        {
          title: '操作后状态',
          dataIndex: 'checkStatus',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList(1022),
          render: (props) => {
            console.log(props.row.checkStatus);
            return <span>{this.createDictText(props.row.checkStatus, 1022)}</span>;
          },
        },
        {
          title: '审核说明',
          dataIndex: 'checkRemarks',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
      ];
    },

    /*配件*/
    createTableColumnPeij() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          fixed: 'left',
          render: (props) => {
            return <span>{props.row.index + 1}</span>;
          },
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          render: (props) => {
            return (
              <div>
                <el-button size="mini" type="text" disabled={this.disableState} onClick={() => this.peijDelFun(props.row)}>
                  删除
                </el-button>
              </div>
            );
          },
        },
        {
          title: '备件代码',
          dataIndex: 'partCode',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '备件名称',
          dataIndex: 'partName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '单位',
          dataIndex: 'unit',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [],
          // dictItems: []
        },
        {
          title: '数量',
          dataIndex: 'counts',
          sorter: true,
          filter: true,
          editType: 'input',
          // filterItems: [],
          editRequired: true,
          editPattern: /^(\d+)(\.?)(\d{0,2})$/,
          editable: true,
          // rules: [
          //   { required: true, message: '请输入数量...', trigger: 'blur' },
          //   {
          //     validator: (rule, value, callback) => {
          //       let reg = /^(\d+)(\.?)(\d{0,2})$/;
          //       if (!reg.test(Number(value))) {
          //         return callback(new Error('数量,最多2位小数...'));
          //       }
          //       callback();
          //     },
          //     trigger: 'blur',
          //   },
          // ],
        },
        {
          title: '账类',
          dataIndex: 'costType',
          sorter: true,
          disabled: true,
          editType: 'select',
          initialValue: '',
          // disabled: this.handleType == 'edit' ? true : false,
          editItems: this.createDictList('5803', [58031001, 58031003, 58031004]),
          // render: (props) => {
          //   return <span>{this.createDictText(props.row.costType,'5803')}</span>
          // },
          editable: true,
        },

        {
          title: '关联维修工时',
          dataIndex: 'mlId',
          sorter: true,
          editType: 'select',
          editRequired: true,
          editItems: this.sportArr,
          disabled: this.handleType == 'edit' ? true : false,
          initialValue: '请选择',
          render: (props) => {
            const { sportArr } = this;
            console.log('this=======', props.row.mlId, sportArr);
            if (!sportArr.length) {
              props.row.mlId = '';
            } else {
              let hasLabourId = sportArr.find((item) => item.labourId == props.row.mlId);
              if (!hasLabourId) {
                props.row.mlId = '';
              }
            }

            return (
              <div>
                <el-select v-model={props.row.mlId} onChange={this.cheageselect(props.row)} placeholder="请选择">
                  {sportArr.map((item) => (
                    <el-option key={item.labourId} label={item.labourName} value={item.labourId} />
                  ))}
                </el-select>
              </div>
            );
          },
          editable: true, //mark
        },

        // {
        //   title: '配件渠道',
        //   dataIndex: 'partFrom',
        //   sorter: true,
        //   editType: 'select',
        //   editItems: this.createDictList('1025'),
        //   // this.createDictList('1025')
        //   editRequired: true,
        //   // editPattern:/^[1][3,4,5,7,8][0-9]{9}$/,
        //   editable: true
        // },
        // {
        //   title: '索赔总价',
        //   dataIndex: 'amount',
        //   sorter: true,
        //   filter: true,
        //   filterType: 'input',
        //   precision: 2
        // },
      ];
    },

    //附加项目
    createTableColumnFuj() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          fixed: 'left',
          render: (props) => {
            return <span>{props.row.index + 1}</span>;
          },
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          render: (props) => {
            return (
              <div>
                <el-button size="mini" type="text" disabled={this.disableState} onClick={() => this.fujDelFun(props.row)}>
                  删除
                </el-button>
              </div>
            );
          },
        },
        {
          title: '项目代码',
          dataIndex: 'itemCode',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '项目名称',
          dataIndex: 'itemName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '项目费用',
          dataIndex: 'itemPrice',
          sorter: true,
          filter: true,
          filterItems: [],
          filterType: 'checkbox',
          // editPattern:/^[1][3,4,5,7,8][0-9]{9}$/,
          editable: true,
          render: (props) => {
            return props.row.itemPrice.toFixed(2);
          },
        },

        {
          title: '账类',
          dataIndex: 'costType',
          sorter: true,
          disabled: true,
          editType: 'select',
          // disabled: this.handleType == 'edit' ? true : false,
          initialValue: '',
          editItems: this.createDictList('5803', [58031001, 58031003, 58031004]),
          editable: true,

          // this.createDictText
        },
        {
          title: '项目说明',
          dataIndex: 'itemRemark',
          sorter: true,
          filter: true,
          filterItems: [],
          editable: true,
          filterType: 'input',
        },
      ];
    },

    /*活动*/
    createTableColumnSport() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          fixed: 'left',
          render: (props) => {
            return <span>{props.row.index + 1}</span>;
          },
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          render: (props) => {
            return (
              <div>
                <el-button size="mini" type="text" disabled={this.disableState} onClick={() => this.sportDelFun(props.row)}>
                  删除
                </el-button>
              </div>
            );
          },
        },
        //  {
        //   // title: '维修工时代码',
        //   dataIndex: 'mlId',
        //   sorter: true,
        //   // filter: true,
        //   filterType: 'hidden'
        // },
        {
          title: '工时代码',
          dataIndex: 'labourCode',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true,
        },
        {
          title: '工时名称',
          dataIndex: 'labourName',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true,
        },
        {
          title: '工时数',
          dataIndex: 'stdLabourHour',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true,
        },
        {
          title: '账类',
          dataIndex: 'costType',
          sorter: true,
          editType: 'select',
          initialValue: '',
          disabled: true,
          editItems: this.createDictList('5803', [58031001, 58031003, 58031004]),
          editable: true,
          editRequired: true,
        },
      ];
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          fixed: 'left',
          render: (props) => {
            return <span>{props.row.index + 1}</span>;
          },
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          render: (props) => {
            return (
              <div>
                <el-button size="mini" type="text" disabled={this.disableState} onClick={() => this.vinDelFun(props.row)}>
                  删除
                </el-button>
              </div>
            );
          },
        },
        {
          title: 'VIN',
          dataIndex: 'vin',
          // width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true,
        },
        {
          title: '车型',
          dataIndex: 'modelName',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true,
        },

        {
          title: '责任站代码',
          dataIndex: 'dealerCode',
          sorter: true,
          filter: true,
          filterType: 'input',
          // editRequired: true,
        },
        {
          title: '责任站简称',
          dataIndex: 'dealerName',
          sorter: true,
          filter: true,
          filterType: 'input',
          // editRequired: true,
        },

      ];
    },
  },
};
</script>

<style scoped lang="less">
.bg1 {
  border: 1px solid @borderColor;
  border-radius: @borderRadius;
  box-shadow: @boxShadow;
  padding: @modulePadding;
  padding-left: 0;
  padding-top: 15px;
  padding-bottom: 15px;
}
.bg2 {
  margin-top: 10px;
  margin-bottom: 10px;
}

.btn {
  text-align: center;
}

.btnStyle {
  margin-top: 10px;
}
</style>
